Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
jalali-moment
Advanced tools
Jalali (Persian, Khorshidi, Shamsi) calendar system to use in javascript or typescript.
A Jalali (Jalali, Persian, Khorshidi, Shamsi) calendar system plugin for moment.js. DEMO
Jalali calendar is a solar calendar. It gains approximately 1 day on the Julian calendar every 128 years. Read more on Wikipedia.
This plugin adds Jalali calendar support to momentjs library.
Calendar conversion is based on the algorithm provided by Kazimierz M. Borkowski and has a very good performance.
Like momentjs
, jalali-moment
works in browser and in Node.js.
Install via NPM
npm install jalali-moment -S
Install via bower
bower install jalali-moment --save
var moment = require('jalali-moment');
moment().format('jYYYY/jM/jD');
import * as moment from 'jalali-moment';
add a jalali pipe
@Pipe({
name: 'jalali'
})
export class JalaliPipe implements PipeTransform {
transform(value: any, args?: any): any {
let MomentDate = moment(value);
return MomentDate.format("jYYYY/jM/jD");
}
}
and use it in component template
<div>{{ loadedData.date | jalali }}</div>
import * as moment from 'jalali-moment';
let todayJalali = moment().format('jYYYY/jM/jD');
<!--<script src="bower_components/jalali-moment/dist/jalali-moment.browser.js"></script>-->
<!--<script src="node_modules/jalali-moment/dist/jalali-moment.browser.js"></script>-->
<script src="thisRepository/jalali-moment/dist/jalali-moment.browser.js"></script>
<script>
moment().format('jYYYY/jM/jD');
</script>
<script src='https://unpkg.com/jalali-moment/dist/jalali-moment.browser.js'></script>
<script>
moment().format('jYYYY/jM/jD');
</script>
You could use systemjs to import this library into your project like this
This plugin tries to mimic moment.js api. Basically, when you want to format or parse a string, just add a j
to the format token like 'jYYYY' or 'jM'. For example:
m = moment('1367/11/4', 'jYYYY/jM/jD');
m.format('jYYYY/jM/jD [is] YYYY/M/D'); // 1367/11/4 is 1989/1/24
m.jDayOfYear(); // 310
m.jWeek(); // 45
m.jWeekYear(); // 1367
moment.jIsLeapYear(m.jYear()); // false
m.jYear(1368); // set jalali year
m.jMonth(); // 10
// jMonth Accepts numbers from 0 to 11. If the range is exceeded, it will bubble up to the year.
m.jMonth(3); // set a jalali month
m.jDate(10); // set a date
m.format("jYYYY/jMM/jD"); // 1368/4/10
m.subtract(1, "jyear"); // add a Jalali Year
m.format("jYYYY/jMM/jD"); // 1367/4/10
m.add(2, "jmonth"); // add Jalali Month
m.format("jYYYY/jMM/jD"); // 1367/6/10
moment('1392/6/3 16:40', 'jYYYY/jM/jD HH:mm')
.format('YYYY-M-D HH:mm:ss'); // 2013-8-25 16:40:00
moment('2013-8-25 16:40:00', 'YYYY-M-D HH:mm:ss')
.endOf('jMonth')
.format('jYYYY/jM/jD HH:mm:ss'); // 1392/6/31 23:59:59
moment('1981 5 17', 'YYYY jM D')
.format('YYYY/MM/DD'); // 1981/07/17
for more information about api you could read moment.js.
To add Persian language, use loadPersian method:
moment().format('jYYYY/jMMMM/jD'); // 1367/Bahman/4
moment.loadPersian();
moment().format('jYYYY/jMMMM/jD'); // 1367/بهمن/4
moment.loadPersian(true);
moment().format('jYYYY/jMMMM/jD'); // ۱۳۶۷/بهمن/۴
moment.unloadPersian();
moment().format('jYYYY/jMMMM/jD'); // 1367/Bahman/4
A highly configurable date picker built for Angular 2 applications using jalali-moment
is fingerpich/jalali-angular-datepicker created by @Fingerpich.
MIT
FAQs
Manipulate and convert Jalali and Gregorian date easily
The npm package jalali-moment receives a total of 7,401 weekly downloads. As such, jalali-moment popularity was classified as popular.
We found that jalali-moment demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.